package com.lean.android.ad.duration.database

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import com.lean.android.ad.duration.database.dao.AppDurationDao
import com.lean.android.ad.duration.database.dao.PageDurationDao
import com.lean.android.ad.duration.database.entities.AppDurationEntity
import com.lean.android.ad.duration.database.entities.PageDurationEntity

@Database(
    version = 1,
    entities = [AppDurationEntity::class, PageDurationEntity::class]
)
internal abstract class DurationDatabase : RoomDatabase() {

    companion object {

        private const val DB_NAME = "app-duration"

        fun createDatabase(context: Context): DurationDatabase {
            return Room.databaseBuilder(context, DurationDatabase::class.java, DB_NAME)
                .fallbackToDestructiveMigration()
                .build()
        }
    }

    abstract fun getAppDurationDao(): AppDurationDao

    abstract fun getPageDurationDao(): PageDurationDao
}